const VueLoaderPlugin = require('vue-loader/lib/plugin')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const GitRevisionPlugin = require('git-revision-webpack-plugin')
const wpUtils = require('./webpackUtils')
const {resolve} = require('path')
wpUtils.syncGitVersion()
module.exports = {
  "entry": {
    app: resolve(__dirname, "../resources/assets/js/app.ts")
  },
  "output": {
    "path": resolve(__dirname, '../public/js'),
    "filename": "[name].[git-revision-version].js"
  },
  "resolve": {
    "alias": {
      "vue$": 'vue/dist/vue.esm.js'
    },
  },
  "devtool": "source-map",
  "module": {
    "rules": [
      {
        "test": /\.tsx?$/,
        "exclude": /node_modules/,
        "use": {
          "loader": "ts-loader",
          "options": {
            "appendTsSuffixTo": [/\.vue$/],
            "transpileOnly": true
          }
        }
      },
      {
        "test": /\.vue$/,
        "exclude": /node_modules/,
        "use": "vue-loader"
      },
      {
        "test": /\.scss$/,
        "use": [
          "style-loader",
          "css-loader",
          "sass-loader"
        ]
      }
    ]
  },
  plugins: [
    new CleanWebpackPlugin([resolve(__dirname, '../public/js')], {
      root: resolve(__dirname, '..')
    }),
    new VueLoaderPlugin(),
    new GitRevisionPlugin()
  ]
}